#include "DObject.hpp"
#include "DGlobals.hpp"
#include "DUtils.hpp"

namespace Distillate {

DObject::DObject(float X, float Y, float Width, float Height):
	DRect(X,Y,Width,Height),
	_flicker(0),
	_flickerTimer(-1),
	_group(false),
	exists(true),
	visible(true),
	_solid(true),
	fixed(false),
	angle(0),
	angularVelocity(0),
	angularAcceleration(0),
	angularDrag(0),
	maxAngular(10000),
	thrust(0),
	health(1),
	dead(false),
	moves(true),
	collideLeft(true),
	collideRight(true),
	collideTop(true),
	collideBottom(true) {}

DObject::~DObject() {
	//dtor
}

void destroy() {

}

void DObject::refreshHulls() {
	colHullX.x = x;
	colHullX.y = y;
	colHullX.width = width;
	colHullX.height = height;
	colHullY.x = x;
	colHullY.y = y;
	colHullY.width = width;
	colHullY.height = height;
}

void DObject::updateMotion() {
	if(!moves)
		return;

	if(_solid)
		refreshHulls();
	onFloor = false;
	int vc;

	/*

	vc = (FlxU.computeVelocity(angularVelocity,angularAcceleration,angularDrag,maxAngular) - angularVelocity)/2;
	angularVelocity += vc;
	angle += angularVelocity*FlxG.elapsed;
	angularVelocity += vc;

	var thrustComponents:FlxPoint;
	if(thrust != 0)
	{
	    thrustComponents = FlxU.rotatePoint(-thrust,0,0,0,angle);
	    var maxComponents:FlxPoint = FlxU.rotatePoint(-maxThrust,0,0,0,angle);
	    var max:Number = ((maxComponents.x>0)?maxComponents.x:-maxComponents.x);
	    if(max > ((maxComponents.y>0)?maxComponents.y:-maxComponents.y))
	        maxComponents.y = max;
	    else
	        max = ((maxComponents.y>0)?maxComponents.y:-maxComponents.y);
	    maxVelocity.x = maxVelocity.y = ((max>0)?max:-max);
	}

	*/
}

void DObject::updateFlickering() {

}

void DObject::update() {
	updateMotion();
	updateFlickering();
}

bool DObject::overlaps(DObject *Object) {
	return false;
}

bool DObject::overlapsPoint(float X,float Y,bool PerPixel) {
	return false;
}

bool DObject::collide(DObject *Object) {
	return true;
}

void DObject::hitLeft(DObject *Contact, float Velocity) {
}

void DObject::hitRight(DObject *Contact, float Velocity) {
}

void DObject::hitTop(DObject *Contact, float Velocity) {
}

void DObject::hitBottom(DObject *Contact, float Velocity) {
}

void DObject::hurt(int Damage) {
}

void DObject::kill() {
}

void DObject::flicker(int Duration) {
}

bool DObject::flickering() {
	return _flickerTimer >= 0;
}

DPoint* DObject::getScreenXY(DPoint *Point) {
	return NULL;
}

bool DObject::onScreen() {
	return true;
}

void DObject::reset(float X, float Y) {
}



}
